app.controller('brandController', function ($scope, $controller, brandService) {

    $controller('baseController', {$scope: $scope});

    //新增品牌或者修改品牌
    $scope.save = function () {
        var object = null;
        if ($scope.entity.id != null) {
            object = brandService.updateBrand($scope.entity);
        } else {
            object = brandService.addBrand($scope.entity);
        }
        object.success(
            function (response) {
                if (response.success) {
                    $scope.reloadList();
                } else {
                    alert(response.message);
                }
            }
        )
    }
    //根据品牌编号查询品牌信息
    $scope.findBrandById = function (id) {
        brandService.findBrandById(id).success(
            function (response) {
                $scope.entity = response;
            }
        )
    }

    //删除品牌
    $scope.dele = function () {
        brandService.deleteBrand($scope.selectIds).success(
            function (response) {
                if (response.success) {
                    $scope.reloadList();
                } else {
                    alert(response.message);
                }
            }
        )
    }

    $scope.searchEntity = {};
    //品牌列表搜索
    $scope.search = function (page, size) {
        brandService.search(page, size, $scope.searchEntity).success(
            function (response) {
                $scope.list = response.rows;
                $scope.paginationConf.totalItems = response.total;
            }
        )
    }

});